<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>微信安全支付</title>
    <meta id="viewport" name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1; user-scalable=no;">
    <meta name="format-detection" content="telephone=no">
    <link href="/static/api/wexin/b/loading.css" rel="stylesheet">
    <link href="/static/api/wexin/b/pop.css" rel="stylesheet">
    <script type="text/javascript">
        function query() {
            doRequestUsingGet('{$host}/BoxYunPay/checkYunOrderPay?order_num={$order_num}');
        }

        window.setInterval(query, "2000");
        var xmlHttp;

        function createxmlHttpRequest() {
            if (window.ActiveXObject)
                xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
            else if (window.XMLHttpRequest)
                xmlHttp = new XMLHttpRequest();
        }


        function doRequestUsingGet(queryUrl) {
            createxmlHttpRequest();
            var queryString = queryUrl;
            queryString += "&timestamp=" + new Date().getTime();
            xmlHttp.open("GET", queryString);
            xmlHttp.onreadystatechange = handleStateChange;
            xmlHttp.send(null);
        }

        function handleStateChange() {
            var obj = eval('(' + xmlHttp.responseText + ')');
            if (obj.code == '200') {
                if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
                    window.webkit.messageHandlers.closeWebview.postMessage(null);
                } else if (/(Android)/i.test(navigator.userAgent)) {
                    window.android.closeWebview('');
                }
            }
        }

        function getCookie(cname) {
            var name = cname + "=";
            var ca = document.cookie.split(';');
            for (var i = 0; i < ca.length; i++) {
                var c = ca[i];
                while (c.charAt(0) == ' ') c = c.substring(1);
                if (c.indexOf(name) != -1) return c.substring(name.length, c.length);
            }
            return null;
        }

        function setCookie(name, value) {
            var exp = new Date();
            exp.setTime(exp.getTime() + 10 * 60 * 1000);
            document.cookie = name + "=" + value + ";expires=" + exp.toGMTString();
        }

        function onloadAction() {
            setTimeout(function () {
                var url = "{$pay_url|raw}";
                var orderNum = "{$order_num}";
                var o = getCookie(orderNum);
                if(o == null){
                    setCookie(orderNum, "1");
                    window.location.href = url;
                }
            }, 100);
        }

        function doCallback() {
            var isIOS = /iPhone/i.test(navigator.userAgent) || /iPad/i.test(navigator.userAgent) || /iPod/i.test(navigator.userAgent) || /Mac/i.test(navigator.userAgent),
                isAndroid = /Android/i.test(navigator.userAgent);
            if (isIOS) {
                window.webkit.messageHandlers.closeWebview.postMessage('');
            } else if (isAndroid) {
                window.android.closeWebview('');
            }
        }

    </script>
</head>
<body onload="onloadAction()">
<div class="loading_wrap">
    <span class="loading animate"></span>
</div>
<div class="pop_wraper" id="alert_box1">
    <div class="pop_outer pop_midder">
        <div class="pop_tip">
            <p class="pop_tip_p4">支付确认</p>
            <p class="pop_tip_p5">1、请在微信内完成支付，支付成功页面自动跳转</p>
            <p class="pop_tip_p5">2、如果您未支付，请点击“去支付”完成支付</p>
            <p class="pop_tip_p5">3、如果您未安装微信6.0.2版本及以上版本客户端，请先安装并登陆微信完成支付</p>
            <p class="pop_tip_p3 border b_top">
                <span class="border b_rgt"><button class="p_btn" onclick="doCallback()">关闭</button></span>
                <span><a id="cli" class="p_btn cols" style="text-decoration: none" href="{$pay_url}">去支付</a></span>
            </p>
        </div>
    </div>
</div>

</body>
</html>
